﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using ParserGenerator.Extensions;

namespace ParserGenerator.Collections
{
    public static class ReadOnlyDictionary
    {
        public static ReadOnlyDictionary<TKey, TValue> GetEmpty<TKey, TValue>()
        {
            return new Dictionary<TKey, TValue>().AsReadOnly();
        }

        public static ReadOnlyDictionary<TKey, TValue> New<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>> collection)
        {
            if (collection == null)
                throw new ArgumentNullException(nameof(collection));
            return Dictionary.New(collection).AsReadOnly();
        }

        public static ReadOnlyDictionary<TKey, TValue> Create<TKey, TValue>(params KeyValuePair<TKey, TValue>[] items)
        {
            if (items == null)
                throw new ArgumentNullException(nameof(items));
            return New(items);
        }
    }
}
